/**
 * 结算窗口
 */
var ZongJieSuanWindow = Window.extend({
    /**
     * 复制分享文本
     */
    _infoText: '',
    /**
     * 总结算数据
     */
    _data: null,
    /**
     * 初始化
     * @param data
     */
    initWindow: function (data, clubId) {
        this._super();
        this._data = data;
        this._clubId = clubId;
        this._initInfo(this._data);
        if (window.inReview) {
            safeHide(this._nodeList['btn_share']);
        }
    },
    /**
     * 点击时间
     * @private
     */
    _initClickListeners: function () {
        this._super();
        this._clickListeners = {
            'btn_return': '_clickReturn',
            'btn_share': '_clickShare',
            'btn_copy': '_clickCopy',
            'btn_sharelianjie': '_clickSharelianjie'
        };
    },
    /**
     * 关闭界面
     * @public
     */
    close: function () {
        showBoard('HallBoard');
    },
    /**
     *返回大厅
     * @private
     */
    _clickReturn: function () {
        showBoard('HallBoard');
    },
    /**
     *分享
     * @protected
     */
    _clickShare: function () {
        ShareUtil.SharePic(this);
    },
    /**
     *分享战绩
     * @private
     */
    _clickSharelianjie: function () {
        var self = this;
        var players = deepCopy(self._data.players);
        players = players.sort(function (a, b) {
            return a.score < b.score;
        });
        var fenshu = "";
        for (var i = 0; i < players.length; i++) {
            var player = players[i];
            var uid = player['uid'];
            var score = player['score'];
            var playerInfo = gameData.getPlayerInfoByUid(uid);
            fenshu = fenshu + playerInfo.nickname + ":【" + score + "】,";
        }
        fenshu = fenshu.substring(0, fenshu.length - 1);

        var players = self._data.players;
        ShareUtil.ShareZhanJi(gameData.roomId, players[0]['uid'], players[1]['uid'], this, fenshu);

    },
    /**
     *复制信息
     * @private
     */
    _clickCopy: function () {
        DeviceUtil.savePasteBoard(this._infoText);
        showToast('您的信息已复制');
    },
    /**
     * 初始化窗口
     * @param data
     * @private
     */
    _initInfo: function (data) {

    }
});